<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 2.1数组 let 数组名 = [数据1，数据2，.......]
    //求和和平均数 数组遍历说是
    let arr = [2, 6, 1, 7, 4]
    let sum = 0
    let pj = 0
    for (i = 0; i < arr.length; i++) {
      sum += arr[i]
      pj = sum / arr.length
      console.log(sum);
      console.log(pj);
    }
    //最大值

    let arr1 = [2, 6, 1, 77, 52, 25, 7];
    let max = arr1[0];
    for (let i = 1; i < arr1.length; i++) {
      if (arr1[i] > max) {
        max = arr1[i];
      }
    }
    console.log('最大值：' + max);


    let min = arr1[0];
    for (let i = 1; i < arr1.length; i++) {
      if (arr1[i] < min) {
        min = arr1[i];
      }
    }
    console.log('最小值：' + min); 
  </script>
</body>

</html>


</script>
</body>

</html>